unit uMainForm;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ToolWin, ActnMan, ActnCtrls, Menus, ComCtrls, ExtCtrls, CustomizeDlg,
  PlatformDefaultStyleActnCtrls, ActnList, ImgList, BandActn, StdActns,SqlExpr,DB,
  uRoomControl;

type
  TMainForm = class(TForm)
    ImageList: TImageList;
    ActionManager: TActionManager;
    CustomizeDlg: TCustomizeDlg;
    Timer: TTimer;
    StatusBar: TStatusBar;
    MainMenu: TMainMenu;
    mnuFile: TMenuItem;
    mnuControl: TMenuItem;
    mnuTools: TMenuItem;
    mnuHelp: TMenuItem;
    ActionToolBar1: TActionToolBar;
    WindowClose1: TWindowClose;
    WindowCascade1: TWindowCascade;
    WindowTileHorizontal1: TWindowTileHorizontal;
    WindowTileVertical1: TWindowTileVertical;
    WindowMinimizeAll1: TWindowMinimizeAll;
    WindowArrange1: TWindowArrange;
    Action1: TAction;
    mnuWindow: TMenuItem;
    Cascade1: TMenuItem;
    WindowTileHorizontally: TMenuItem;
    WindowArrange: TMenuItem;
    WindowClose: TMenuItem;
    CustomizeActionBars1: TCustomizeActionBars;
    Customize1: TMenuItem;
    MinimizeAll1: TMenuItem;
    ileVertically1: TMenuItem;
    N1: TMenuItem;
    mnuUser: TMenuItem;
    Close: TMenuItem;
    Room1: TMenuItem;
    MeetingManager1: TMenuItem;
    acClose: TAction;
    acUser: TAction;
    acRoom: TAction;
    acMeetingManager: TAction;
    procedure TimerTimer(Sender: TObject);
    procedure acCloseExecute(Sender: TObject);
    procedure acUserExecute(Sender: TObject);
    procedure acRoomExecute(Sender: TObject);
    procedure acMeetingManagerExecute(Sender: TObject);
    procedure FormShow(Sender: TObject);
  private
    FDBConnection: TSQLConnection;
    procedure SetDBConnection(const Value: TSQLConnection);
    { Private declarations }
  public
    { Public declarations }
    property DBConnection:TSQLConnection read FDBConnection write SetDBConnection;
  end;

var
  MainForm: TMainForm;

implementation
uses uUserControl,uMeetingControl;
{$R *.dfm}



procedure TMainForm.acCloseExecute(Sender: TObject);
begin
  Application.Terminate;
end;

procedure TMainForm.acRoomExecute(Sender: TObject);
begin
  inherited;
  TRoomControl.GetInstance.CreateDefaultForm;
end;

procedure TMainForm.acMeetingManagerExecute(Sender: TObject);
begin
  inherited;
  TMeetingControl.GetInstance.CreateDefaultForm;
end;

procedure TMainForm.acUserExecute(Sender: TObject);
begin
  TUserControl.GetInstance.CreateDefaultForm;
end;

procedure TMainForm.FormShow(Sender: TObject);
begin
  inherited;
  StatusBar.Panels[2].Text:='Welcome '+TUserControl.GetInstance.fUserName ;
  StatusBar.Panels[3].Text:='Is Admin: ';

  acUser.Enabled:=TuserControl.GetInstance.fUserIsAdmin;
  acRoom.Enabled:=TUserControl.GetInstance.fUserIsAdmin;

  if TUserControl.GetInstance.fUserIsAdmin then
    StatusBar.Panels[3].Text:=StatusBar.Panels[3].Text+'YES'
  else
    StatusBar.Panels[3].Text:=StatusBar.Panels[3].Text+'NO';

end;

procedure TMainForm.SetDBConnection(const Value: TSQLConnection);
begin
  FDBConnection := Value;
end;

procedure TMainForm.TimerTimer(Sender: TObject);
begin
  StatusBar.Panels[0].Text:='Data: ' + DateToStr(Date);
  StatusBar.Panels[1].Text:='Time: ' + TimeToStr(Time);
end;

end.
